//--------------------------------------------------- // Purpose: User input with error checking. // Author: John Gauch //--------------------------------------------------- #include #include using namespace std; int main() { int amount = 0; while (amount <= 0) { // Get user input cout << "Enter amount > 0: "; string input; cin >> input; // Convert string to integer try { amount = stoi(input); } catch (...) { cout << "Error: invalid input type" << endl; } } cout << "Amount was: " << amount << endl; return 0; }